package moni.anyou.com.view.view;
import java.lang.reflect.Field;
import java.util.*;

import android.annotation.TargetApi;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
        import android.os.Handler;
        import android.os.Message;
        import android.os.Bundle;
        import android.util.Log;
        import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
        import android.widget.TextView;
        import android.widget.Toast;
        import com.google.gson.Gson;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.readystatesoftware.systembartint.SystemBarTintManager;

import org.json.JSONArray;
import org.json.JSONObject;
        import org.kymjs.aframe.http.KJHttp;
        import org.kymjs.aframe.http.KJStringParams;
        import org.kymjs.aframe.http.StringCallBack;
        import java.io.File;
        import java.util.ArrayList;
        import java.util.List;

import moni.anyou.com.view.R;
import moni.anyou.com.view.base.BaseActivity;
import moni.anyou.com.view.config.SysConfig;
import moni.anyou.com.view.tool.AppTools;
import moni.anyou.com.view.tool.PermissionTools;
import moni.anyou.com.view.tool.ToastTools;
import moni.anyou.com.view.tool.Tools;
import moni.anyou.com.view.tool.UploadUtil;
import moni.anyou.com.view.view.photo.PhotoDialog;
import moni.anyou.com.view.widget.NetProgressWindowDialog;
import moni.anyou.com.view.widget.dialog.MessgeDialog;
import moni.anyou.com.view.widget.pikerview.TimeSelector;
import moni.anyou.com.view.widget.pikerview.view.RelationSeletor;
import moni.anyou.com.view.widget.utils.imageload.ImageLoadUtil;

public class AddTeamActivity extends BaseActivity implements View.OnClickListener {
    private NetProgressWindowDialog window;
    private ImageView ivUpload;
    private TextView tvScheduling;
    private TextView tvActivityFee;
    private TextView tvRemark;
    private TextView tvContact;
    private TextView tvEquipment;
    private TextView tvDisclaimer;
    private TextView tvStartTime;
    private TextView tvEndTime;
    private TextView tvRouteName;
    private TextView tvTeamName;
    private RelativeLayout rlTeamName;
    private RelativeLayout rlRouteName;
    private RelativeLayout rlStartTime;
    private RelativeLayout rlEndTime;
    private TextView tvActivityStrength;
    private RelativeLayout rlScheduling;
    private RelativeLayout rlActivityFee;
    private RelativeLayout rlDisclaimer;
    private RelativeLayout rlEquipment;
    private RelativeLayout rlActivityStrength;
    private RelativeLayout rlContact;
    private RelativeLayout rlRemark;
    private RelativeLayout rlUpload;
    private LinearLayout llUpload;
    private RelationSeletor mSexSeletor;
    private String routeID = "";
    ArrayList<String> mStringrRoute = new ArrayList<>();
    private String mType;
    private String mVaule;
    private String mTypeName;
    private String upLoadfile = "";
    private String teamPic = "";  //封面图
    private TimeSelector mStartTimeSelector;
    private TimeSelector mEndTimeSelector;
    private JSONArray routeList = new JSONArray();
    private JSONArray teamInfo = new JSONArray();
    private String teamid = "0";
    private String typeid = "0";
    ArrayList<String> mStringRelations = new ArrayList<>();
    String[] strInput = {"teampic","teamname","starttime","endtime","routeid","activitystrength","scheduling","contact","activityfee","equipment","disclaimer","remark"};
    String[] strInputName = {"封面图","团队名称","开始时间","结束时间","徒步路线","活动强度","行程安排","联系方式","费用说明","个人装备","免责声明","备注"};
    private HashMap  map =   new HashMap();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_addteam);
        initState();
        initWindow();
        teamid = getIntent().getStringExtra("teamID");
        init();

        LogOut.getInstance().addActivity(this);
    }

    @Override
    public void initView() {
        super.initView();
        initTitle();
        mPhotoDialog = new PhotoDialog(mBaseActivity, PhotoDialog.SmallSize);
        window = new NetProgressWindowDialog(mBaseActivity);
        tvTitle.setText("添加组团信息");
        tvRight.setText("保存");
        tvRight.setVisibility(View.VISIBLE);
        tvTeamName =  findViewById(R.id.tv_teamName);
        rlTeamName = (RelativeLayout) findViewById(R.id.rl_teamName);
        rlScheduling = (RelativeLayout) findViewById(R.id.rl_scheduling);
        rlActivityFee = (RelativeLayout) findViewById(R.id.rl_activityFee);
        rlContact = (RelativeLayout) findViewById(R.id.rl_contact);
        rlRouteName = (RelativeLayout) findViewById(R.id.rl_routeName);
        rlEquipment = (RelativeLayout) findViewById(R.id.rl_equipment);
        rlDisclaimer = (RelativeLayout) findViewById(R.id.rl_disclaimer);
        rlActivityStrength = (RelativeLayout) findViewById(R.id.rl_activityStrength);
        rlRemark = (RelativeLayout) findViewById(R.id.rl_remark);
        llUpload = (LinearLayout) findViewById(R.id.ll_upload);
        rlUpload = (RelativeLayout) findViewById(R.id.rl_upload);
        ivUpload = (ImageView) findViewById(R.id.iv_upload);
        tvScheduling = (TextView) findViewById(R.id.tv_scheduling);
        tvActivityFee = (TextView) findViewById(R.id.tv_activityFee);
        tvContact = (TextView) findViewById(R.id.tv_contact);
        tvEquipment = (TextView) findViewById(R.id.tv_equipment);
        tvDisclaimer = (TextView) findViewById(R.id.tv_disclaimer);
        tvActivityStrength = (TextView) findViewById(R.id.tv_activityStrength);
        tvRemark = (TextView) findViewById(R.id.tv_remark);
        tvRouteName = (TextView) findViewById(R.id.tv_routeName);
        rlStartTime = (RelativeLayout)findViewById(R.id.rl_startTime);
        rlEndTime = (RelativeLayout)findViewById(R.id.rl_endTime);
        tvStartTime = (TextView) findViewById(R.id.tv_startTime);
        tvEndTime = (TextView)findViewById(R.id.tv_endTime);
        /*
        try{
            for(int i=0;i<strInput.length;i++) {
                map.put(strInput[i],"");
            }

            setBitmaptoImageView11(SysConfig.PicUrl + SysConfig.userInfoJson.get("icon").toString(),ivUpload);
            tvRemark.setText(SysConfig.userInfoJson.get("companyname").toString());
            map.put("nick",tvNick.getText().toString());
            map.put("smallpic",SysConfig.userInfoJson.get("icon").toString());
            map.put("company",tvRemark.getText().toString());
        }
        catch(Exception ex){

        }
        */
    }

    @Override
    public void setData() {
        super.setData();
        getInitInfo();

    }

    @Override
    public void setAction() {
        super.setAction();
        ivBack.setOnClickListener(this);
        tvRight.setOnClickListener(this);
        rlTeamName.setOnClickListener(this);
        rlUpload.setOnClickListener(this);
        rlStartTime.setOnClickListener(this);
        rlEndTime.setOnClickListener(this);
        rlScheduling.setOnClickListener(this);
        rlActivityFee.setOnClickListener(this);
        rlContact.setOnClickListener(this);
        rlEquipment.setOnClickListener(this);
        rlDisclaimer.setOnClickListener(this);
        rlActivityStrength.setOnClickListener(this);
        rlRemark.setOnClickListener(this);
        rlRouteName.setOnClickListener(this);
        mPhotoDialog.setPhotoListener(mPhotoListener);
    }

    private void initTeamInfo(){
       if (teamInfo.length() > 0){
           try {
               JSONObject json = (JSONObject) teamInfo.get(0);
               int status = json.getInt("status");
               if (status == 1){
                   tvRight.setVisibility(View.INVISIBLE);
               }
               else{
                   if (status == 0 && SysConfig.uid.equals(json.getString("userID"))){
                         typeid = "1";

                   }
                   else{
                       tvRight.setVisibility(View.INVISIBLE);
                   }
               }
               ivUpload.setVisibility(View.VISIBLE);
               ImageLoader imageLoader = ImageLoadUtil.getInstance(mContext).mImageLoader;
               DisplayImageOptions options = new DisplayImageOptions.Builder()
                       .cacheInMemory(true)
                       .cacheOnDisk(true)
                       .considerExifParams(true)
                       .bitmapConfig(Bitmap.Config.RGB_565)
                       .considerExifParams(true)
                       .delayBeforeLoading(0)
                       .resetViewBeforeLoading(true)
                       .displayer(new RoundedBitmapDisplayer(0))
                       .displayer(new FadeInBitmapDisplayer(0))
                       .build();
               imageLoader.displayImage(SysConfig.PicUrl+json.getString("teamPic"),ivUpload,options);
               llUpload.setVisibility(View.GONE);
               tvScheduling.setText(json.getString("scheduling"));
               tvActivityFee.setText(json.getString("activityFee"));
               tvContact.setText(json.getString("contact"));
               tvEquipment.setText(json.getString("equipment"));
               tvDisclaimer.setText(json.getString("disclaimer"));
               tvActivityStrength.setText(json.getString("activityStrength"));
               tvRemark.setText(json.getString("remark"));;
               tvRouteName.setText(json.getString("routeName"));
               tvTeamName.setText(json.getString("teamName"));
               tvStartTime.setText(json.getString("startTime"));
               tvEndTime.setText(json.getString("endTime"));
               // String[] strInput = {"teampic","teamname","starttime","endtime","routeid","activitystrength","scheduling","contact","activityfee","equipment","disclaimer","remark"};
               map.put("teampic",json.getString("teamPic"));
               map.put("teamname",json.getString("teamName"));
               map.put("starttime",json.getString("startTime"));
               map.put("endtime",json.getString("endTime"));
               map.put("routeid",json.getString("routeID"));
               map.put("activitystrength",json.getString("activityStrength"));
               map.put("scheduling",json.getString("scheduling"));
               map.put("contact",json.getString("contact"));
               map.put("activityfee",json.getString("activityFee"));
               map.put("equipment",json.getString("equipment"));
               map.put("disclaimer",json.getString("disclaimer"));
               map.put("remark",json.getString("remark"));

           }
           catch(Exception ex){

           }
       }
    }
    private void initSeleterData() {
        mStringrRoute.clear();
        for(int i=0;i < routeList.length();i++){
            try {
                JSONObject jsonObject = routeList.getJSONObject(i);
                mStringrRoute.add(jsonObject.getString("routeName"));
            }
            catch(Exception ex){

            }

        }
        mSexSeletor = new RelationSeletor(mBaseActivity, mStringrRoute, new RelationSeletor.ResultHandler() {
            @Override
            public void handle(String routeName) {
                    for(int i=0;i < routeList.length();i++){
                        try {
                            JSONObject jsonObject = routeList.getJSONObject(i);
                            if (jsonObject.getString("routeName").equals(routeName)) {
                                {
                                    routeID = jsonObject.getString("routeID");
                                    tvRouteName.setText(routeName);
                                    map.put("routeid",routeID);
                                    break;
                                }
                            }
                        }
                        catch(Exception ex){


                        }
                    }

            }

            @Override
            public void handle(int position) {


            }
        });
        mStartTimeSelector = new TimeSelector(mContext, new TimeSelector.ResultHandler() {
            @Override
            public void handle(String time) {
                if (time != null) {
                    tvStartTime.setText(time);
                    map.put("starttime",time);
                }

            }
        }, Tools.getYeartoDaytime(), Tools.getNextYeartoDaytime() );
        mEndTimeSelector = new TimeSelector(mContext, new TimeSelector.ResultHandler() {
            @Override
            public void handle(String time) {
                if (time != null) {
                    tvEndTime.setText(time);
                    map.put("endtime",time);
                }

            }
        }, Tools.getYeartoDaytime(), Tools.getNextYeartoDaytime() );

    }


    //手机高版本样式
    private void initState() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }

    }

    private SystemBarTintManager tintManager;
    //手机高版本样式
    @TargetApi(19)
    private void initWindow() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            tintManager = new SystemBarTintManager(this);
            tintManager.setStatusBarTintColor(Color.parseColor("#FEC600"));

            tintManager.setStatusBarTintEnabled(true);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            try {
                Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView");
                Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor");
                field.setAccessible(true);
                field.setInt(getWindow().getDecorView(),
                        Color.TRANSPARENT);
            } catch (Exception e) {
            }
        }

    }


    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.iv_left:
                onBack();
                break;
            case R.id.right_tv:
                postUpdateInfo();
                break;
            case R.id.rl_routeName:
                mSexSeletor.show();
                break;
            case R.id.rl_upload:
                mType = "teampic";

                requestPermission(PermissionTools.camera);

                break;
            case R.id.rl_startTime:
                mStartTimeSelector.show();
                break;
            case R.id.rl_endTime:
                mEndTimeSelector.show();
                break;
            case R.id.rl_teamName:
                mType = "teamname";
                mTypeName = "团队名称";
                jump(tvTeamName.getText().toString());
                break;
            case R.id.rl_scheduling:
                mType = "scheduling";
                mTypeName = "行程安排";
                jump(tvScheduling.getText().toString());
                break;
            case R.id.rl_activityFee:
                mType = "activityfee";
                mTypeName = "费用说明";
                jump(tvActivityFee.getText().toString());
                break;
            case R.id.rl_disclaimer:
                mType = "disclaimer";
                mTypeName = "免责声明";
                jump(tvDisclaimer.getText().toString());
                break;
            case R.id.rl_contact:
                mType = "contact";
                mTypeName = "联系方式";
                jump(tvContact.getText().toString());
                break;
            case R.id.rl_equipment:
                mType = "equipment";
                mTypeName = "个人装备";
                jump(tvEquipment.getText().toString());
                break;
            case R.id.rl_activityStrength:
                mType = "activitystrength";
                mTypeName = "活动强度";
                jump(tvActivityStrength.getText().toString());
                break;
            case R.id.rl_remark:
                mType = "remark";
                mTypeName = "备注";
                jump(tvRemark.getText().toString());
                break;
            default:
                break;
        }

    }


   public void jump(String value){
       Intent intent = new Intent();
       intent.putExtra("type",mType);
       intent.putExtra("typename",mTypeName);
       intent.putExtra("value", value);
       intent.setClass(AddTeamActivity.this, EditUserInfoActivity.class);
       startActivityForResult(intent, 99);
   }

     public void postUpdateInfo() {

         String cmdPara = "";
        for(int i=0;i<12;i++) {
            if (map.get(strInput[i]) == null || map.get(strInput[i]).toString().equals("") ) {
                Toast.makeText(mContext,  strInputName[i]+"不能为空", Toast.LENGTH_SHORT).show();
                return ;
            }
            if (cmdPara.equals("")) {
                cmdPara = "\"" + strInput[i] + "\":\""+map.get(strInput[i])+"\"" ;
            }
            else{
                cmdPara += ",\"" + strInput[i] + "\":\""+map.get(strInput[i])+"\"" ;
            }

        }
        String startTime = (String)map.get(strInput[2]);
        String endTime = (String)map.get(strInput[3]);
        if (startTime.compareTo(endTime)>0){
            Toast.makeText(mContext,  "开始时间不能大于结束时间", Toast.LENGTH_SHORT).show();
            return;
         }
         window.ShowWindow();

         if (!upLoadfile.equals("")){
            if (upLoadfile.contains("storage")) {
              UploadUtil.ossUpload(getApplicationContext(),new File(upLoadfile),"team",upLoadfile);
           }
           else {
              Toast.makeText(mContext,  getApplication().getCacheDir() +  "/qianmoFile/" + upLoadfile, Toast.LENGTH_SHORT).show();
              UploadUtil.ossUpload(getApplicationContext(),new File(getApplication().getCacheDir() +  "/qianmoFile/" + upLoadfile),"team",getApplication().getCacheDir() +  "/qianmoFile/" + upLoadfile);
           }
        }

        KJHttp kjh = new KJHttp();
        KJStringParams params = new KJStringParams();
        cmdPara = "{\"cmd\":\"27\",\"uid\":\""+ SysConfig.uid + "\",\"token\":\""+ SysConfig.token + "\",\"typeid\":\""+ typeid +"\",\"teamid\":\""+ teamid +"\","+cmdPara +"}";

        params.put("sendMsg", cmdPara);

        kjh.urlGet(SysConfig.ServerUrl, params, new StringCallBack() {
            @Override
            public void onSuccess(String t) {
                try {
                    JSONObject jsonObject = new JSONObject(t);
                    int result = Integer.parseInt(jsonObject.getString("result"));
                    if (result >= 1) {
                        Toast.makeText(mContext,  jsonObject.get("retmsg").toString(), Toast.LENGTH_LONG).show();
                        finish();
                    } else {
                        if (result == -2) {
                            AppTools.jumptoLogin(mBaseActivity, result);
                        }
                        Toast.makeText(mContext, jsonObject.get("retmsg").toString(), Toast.LENGTH_LONG).show();
                    }
                } catch (Exception ex) {
                    Toast.makeText(mContext, "数据请求失败", Toast.LENGTH_LONG).show();

                }
                window.closeWindow();
            }

            @Override
            public void onFailure(Throwable t, int errorNo, String strMsg) {
                Toast.makeText(mContext, "网络异常，请稍后再试", Toast.LENGTH_LONG).show();

                window.closeWindow();
            }
        });

    }
    //得到初始化组团信息
    public void getInitInfo() {
        window.ShowWindow();
        KJHttp kjh = new KJHttp();
        KJStringParams params = new KJStringParams();
        String cmdPara = "{\"cmd\":\"26\",\"uid\":\""+ SysConfig.uid + "\",\"token\":\""+ SysConfig.token+ "\",\"teamid\":\""+ teamid +"\"}";
        params.put("sendMsg", cmdPara);

        kjh.urlGet(SysConfig.ServerUrl, params, new StringCallBack() {
            @Override
            public void onSuccess(String t) {
                try {

                    JSONObject jsonObject = new JSONObject(t);
                    int result = Integer.parseInt(jsonObject.getString("result"));
                    if (result >= 1) {
                        routeList = ((JSONObject)jsonObject.getJSONArray("list").get(0)).getJSONArray("routeList");
                        initSeleterData();
                        if (!teamid.equals("0")) {
                            teamInfo = ((JSONObject) jsonObject.getJSONArray("list").get(0)).getJSONArray("teamInfo");
                            initTeamInfo();
                        }
                    } else {
                        if (result == -2) {
                            AppTools.jumptoLogin(mBaseActivity, result);
                        }
                        Toast.makeText(mContext, jsonObject.get("retmsg").toString(), Toast.LENGTH_LONG).show();
                    }
                } catch (Exception ex) {
                    Toast.makeText(mContext, "数据请求失败", Toast.LENGTH_LONG).show();

                }
                window.closeWindow();
            }

            @Override
            public void onFailure(Throwable t, int errorNo, String strMsg) {
                Toast.makeText(mContext, "网络异常，请稍后再试", Toast.LENGTH_LONG).show();

                window.closeWindow();
            }
        });
    }



    private String getFileName(String dir){
        //取得最后一个/的下标
        dir = dir.replace("\\","/");
        int index = dir.lastIndexOf("/");
        String newString = dir.substring(index + 1);
        return newString;
    }
    private PhotoDialog mPhotoDialog = null;


    private PhotoDialog.PhotoListener mPhotoListener = new PhotoDialog.PhotoListener() {
        @Override
        public void onSuccess(List<String> photoList) {
            if (null != photoList) {
               final File file = new File(photoList.get(0));

               if (file.exists()) {
                   //ToastTools.showShort(mContext,  photoList.get(0));
                   ivUpload.setVisibility(View.VISIBLE);
                   llUpload.setVisibility(View.GONE);
                   //mContext.setBitmaptoImageView11("file://" + photoList.get(0),);
                       setBitmaptoImageView("file://" + photoList.get(0),  ivUpload, R.drawable.loading_11,
                               R.drawable.loading_err_11, R.drawable.loading_null_11);

                   mType = "teampic";
                   upLoadfile = AppTools.comparese(mContext, photoList.get(0));
                   if (upLoadfile.contains("storage")) {
                       map.put(mType,"team/"+getFileName(upLoadfile));
                   }
                   else {
                       map.put(mType,"team/"+upLoadfile);
                   }

                   //ToastTools.showShort(mContext, filename);
                  /*
                   if (filename.contains(SysConfig.File_DIR)) {
                       map.put(mType,"ads/"+filename);
                       ToastTools.showShort(mContext, getApplication().getCacheDir() + "/qianmoFile/" + filename);

                       upLoadfile = new File (getApplication().getCacheDir() + "/qianmoFile/" + filename);
                       if (upLoadfile.exists()){
                           ToastTools.showShort(mContext, "头像文件存在");
                       }
                       else{
                           ToastTools.showShort(mContext, "头像文件不存在");
                       }

                   } else {
                        map.put(mType,"ads/"+filename);
                        upLoadfile = file;
                   }
                   */
                   // Uri imageUri = Uri.fromFile(file);


                } else {
                    ToastTools.showShort(mContext, "文件不存在");
                }

            }
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError() {

        }

        @Override
        public void onFinish() {

        }
    };



    //不需要授权
    @Override
    public void permissionNoNeed(String permissionName) {
        mPhotoDialog.show();
    }

    //权限授权成功
    @Override
    public void permissionSuccess(String permissionName) {
        mPhotoDialog.show();
    }

    //权限被拒绝
    @Override
    public void permissionRefuse(String permissionName) {
        showMsgDialog("您拒绝了本应用访问相册的权限，无法上传头像，是否授权获取权限？", "暂不授权", "立即授权", new MessgeDialog.MsgDialogListener() {
            @Override
            public void OnMsgClick() {

            }

            @Override
            public void OnLeftClick() {

            }

            @Override
            public void OnRightClick() {
                openPermissionSettingPage(0x1111);
            }

            @Override
            public void onDismiss() {

            }
        });
    }

    //权限之前被拒绝
    @Override
    public void permissionAlreadyRefuse(String permissionName) {
        showMsgDialog("您之前拒绝了本应用访问相册的权限，无法上传头像，是否授权获取权限？", "暂不授权", "立即授权", new MessgeDialog.MsgDialogListener() {
            @Override
            public void OnMsgClick() {

            }

            @Override
            public void OnLeftClick() {

            }

            @Override
            public void OnRightClick() {
                openPermissionSettingPage(0x1111);
            }

            @Override
            public void onDismiss() {

            }
        });
    }

    class UploadThread implements Runnable {

        @Override
        public void run() {
            //int code = UploadUtil.uploadFile(upLoadfile, SysConfig.UploadUrl);
           // UploadUtil.ossUpload(this,upLoadfile,"ads",);

            if (upLoadfile.contains("storage")) {

                UploadUtil.ossUpload(getApplicationContext(),new File(upLoadfile),"ads",upLoadfile);

            } else {

                UploadUtil.ossUpload(getApplicationContext(),new File(getApplication().getCacheDir() +  "/qianmoFile/" + upLoadfile),"ads",getApplication().getCacheDir() +  "/qianmoFile/" + upLoadfile);

            }





                //Message msg = new Message();
               // msg.obj = 1;
                //changeIconHandler.sendMessage(msg);

        }
    }
    /*
    private Handler changeIconHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg != null) {
                //BaseInfo baseInfo = new Gson().fromJson(SysConfig.userInfoJson.toString(), BaseInfo.class);
                //setBitmaptoImageView11(SysConfig.PicUrl + baseInfo.icon, tvHeadIcon);
                if (mType.equals("smallpic")) {
                    System.out.println((SysConfig.PicUrl + map.get(mType).toString()));
                    setBitmaptoImageView11(SysConfig.PicUrl + map.get(mType).toString(), tvHeadIcon);
                   // mContext.setBitmaptoImageView11("file://" + item.filePathName, mViewHold.ivSentPic);
                }
                else{
                    setBitmaptoImageView11(SysConfig.PicUrl + map.get(mType).toString(), rlEquipment);
                }
            }

        }
    };
    */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent temp) {
        switch (resultCode) {
            case 99:
                try {
                    String strType = temp.getExtras().getString("type");
                    String strValue = temp.getExtras().getString("value");
                    map.put(strType,strValue);
                    if (strType.equals("teamname")){
                        tvTeamName.setText(strValue);
                    }
                    if (strType.equals("equipment")){
                        tvEquipment.setText(strValue);
                    }
                    if (strType.equals("remark")){
                        tvRemark.setText(strValue);
                    }
                    if (strType.equals("scheduling")){
                        tvScheduling.setText(strValue);
                    }
                    if (strType.equals("contact")){
                        tvContact.setText(strValue);
                    }
                    if (strType.equals("disclaimer")){
                        tvDisclaimer.setText(strValue);
                    }
                    if (strType.equals("activityfee")) {
                        tvActivityFee.setText(strValue);
                    }
                    else{
                        if (strType.equals("activitystrength")){
                            tvActivityStrength.setText(strValue);
                        }
                    }
                } catch (Exception e) {

                }
                break;
            default:
                break;
        }

    }



}


